/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class Solution {
public:

    long prev = LONG_MIN;
    bool isValidBST(TreeNode* root)
    {
        if (root == nullptr) return true;
        bool Left = isValidBST(root->left);
        if (root->val > prev)prev = root->val;
        else return false;
        bool Right = isValidBST(root->right);

        if (Left && Right)return true;
        else return false;


    }
};